package com.example.yin.controller;

import com.example.yin.common.ErrorMessage;
import com.example.yin.common.SuccessMessage;
import com.example.yin.domain.SysLog;
import com.example.yin.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SysLogController {

    @Autowired
    private SysLogService sysLogService;


    @GetMapping(value = "/log")
    public Object getPageLogs(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize){
        List<SysLog> res = sysLogService.getAll(pageNum,pageSize);
        if(!res.isEmpty()){
            return new SuccessMessage<List<SysLog>>("查询成功",res).getMessage();
        }
        else{
            return new ErrorMessage("查询为空").getMessage();
        }

    }
}
